package com.xoa.controller.performance.leaderAssessment;

import com.xoa.dao.common.SysCodeMapper;
import com.xoa.model.performance.ScoreGroupWithBLOBs;
import com.xoa.model.performance.leaderAssessment.ScoreGroupLeaderWithBLOBs;
import com.xoa.service.performance.leaderAssessment.ScoreGroupLeaderService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/ScoreGroupLeader")
/**
 * 指标集设定
 */
public class ScoreGroupLeaderController {
    @Autowired
    private ScoreGroupLeaderService scoreGroupService;
    @Autowired
    private SysCodeMapper sysCodeMapper;
    @RequestMapping("/assessmentbianji")
    public String score() {
        return "app/hr/leaderAssessment/leaderAssessmentbianji";
    }
    @RequestMapping("/scoreGroup")
    public String scoreGroup() {
        return "app/hr/leaderAssessment/leaderAssessment";
    }
    //进行考核页面
    @RequestMapping("/score")
    public String assessmenting(){
        return "app/hr/leaderAssessment/leaderAssessmenting";
    }


    @RequestMapping("/addScoreGroup")
    @ResponseBody
    public ToJson addScoreGroup(ScoreGroupLeaderWithBLOBs scoreGroup, HttpServletRequest request){

        return scoreGroupService.addScoreGroup(scoreGroup,request);
    }


    @RequestMapping("/delScoreGroupById")
    @ResponseBody
    public ToJson delScoreGroupById(Integer groupId){
        return scoreGroupService.delScoreGroupById(groupId);
    }


    @RequestMapping("/modifyScoreGroup")
    @ResponseBody
    public ToJson modifyScoreGroup(ScoreGroupLeaderWithBLOBs scoreGroup){
        return scoreGroupService.modifyScoreGroup(scoreGroup);
    }


    @RequestMapping("/selScoreGroup")
    @ResponseBody
    public ToJson selScoreGroup(ScoreGroupWithBLOBs scoreGroup,@RequestParam(value = "page",required = false) Integer page,
                                @RequestParam(value = "pageSize",required = false) Integer pageSize,
                                @RequestParam(value="useFlag",required = false) Boolean useFlag){
        return scoreGroupService.selScoreGroup(scoreGroup, page, pageSize, useFlag);
    }


    @RequestMapping("/getChildCode")
    @ResponseBody
    private ToJson getChildCode(String parentNo){
        return scoreGroupService.getChildCode(parentNo);
    }


    @RequestMapping("/cloneScoreGroup")
    @ResponseBody
    public ToJson cloneScoreGroup(Integer groupId, HttpServletRequest request){
        return scoreGroupService.cloneScoreGroup(groupId,request);
    }
}
